<?php $this->pageTitle=Yii::app()->name . ' - '.UserModule::t("Profile");
$this->breadcrumbs=array(
	UserModule::t("Profile"),
);
$this->menu=array(
	((UserModule::isAdmin())
		?array('label'=>UserModule::t('Manage Users'), 'url'=>array('/user/admin'))
		:array()),
    array('label'=>UserModule::t('List User'), 'url'=>array('/user')),
    array('label'=>UserModule::t('Edit'), 'url'=>array('edit')),
    array('label'=>UserModule::t('Change password'), 'url'=>array('changepassword')),
    array('label'=>UserModule::t('Logout'), 'url'=>array('/user/logout')),
);
?>

<div class="row">
	<div class="span9">
		<div style="padding: 10px;">
			<h1 class="theheads"><?php echo UserModule::t('My Profile'); ?></h1>
			
			<?php if(Yii::app()->user->hasFlash('profileMessage')): ?>
			<div class="success">
				<?php echo Yii::app()->user->getFlash('profileMessage'); ?>
			</div>
			<?php endif; ?>
			<table class="dataGrid">
				<tr>
					<th class="thelabel"><?php echo CHtml::encode($model->getAttributeLabel('username')); ?>:</th>
				    <td class="theinfo"><?php echo CHtml::encode($model->username); ?></td>
				</tr>
				<?php 
					$profileFields=ProfileField::model()->forOwner()->sort()->findAll();
					if ($profileFields) {
						foreach($profileFields as $field) {
							//echo "<pre>"; print_r($profile); die();
						?>
				<tr>
					<th class="thelabel"><?php echo CHtml::encode(UserModule::t($field->title)); ?>:</th>
			    	<td class="theinfo"><?php echo (($field->widgetView($profile))?$field->widgetView($profile):CHtml::encode((($field->range)?Profile::range($field->range,$profile->getAttribute($field->varname)):$profile->getAttribute($field->varname)))); ?></td>
				</tr>
						<?php
						}//$profile->getAttribute($field->varname)
					}
				?>
				<tr>
		<th class="thelabel"><?php echo CHtml::encode($model->getAttributeLabel('email')); ?></th>
    	<td class="theinfo"><?php echo CHtml::encode($model->email); ?></td>
	</tr>
	<tr>
					<th class="thelabel"><?php echo CHtml::encode($model->getAttributeLabel('create_at')); ?>:</th>
			    	<td class="theinfo"><?php echo $model->create_at; ?></td>
				</tr>
				<tr>
					<th class="thelabel"><?php echo CHtml::encode($model->getAttributeLabel('lastvisit')); ?>:</th>
			    	<td class="theinfo"><?php echo $model->lastvisit; ?></td>
				</tr>
				<tr>
					<th class="thelabel"><?php echo CHtml::encode($model->getAttributeLabel('status')); ?>:</th>
			    	<td class="theinfo"><?php echo CHtml::encode(User::itemAlias("UserStatus",$model->status)); ?></td>
				</tr>
			</table>
		</div>
	</div>
	<div class="span3">
	<?php
		$this->beginWidget('zii.widgets.CPortlet', array(
			'title'=>'Administration',
		));
		$this->widget('bootstrap.widgets.TbMenu',array(
			'type'=>'list',
			'items'=>$this->menu,
		));
		$this->endWidget();
	?>
	</div>
</div>
